Skip to content

added controller folder with Route controller file#8

Open
narenkarthik370h wants to merge 1 commit intoInAndOut-Stack:mainfrom
narenkarthik370h:feature/route-controller
Open

added controller folder with Route controller file#8
narenkarthik370h wants to merge 1 commit intoInAndOut-Stack:mainfrom
narenkarthik370h:feature/route-controller

Conversation

@narenkarthik370h
Copy link

@narenkarthik370h narenkarthik370h commented Mar 16, 2026

Implements the Route API endpoints defined in the Smithy model:

POST /api/stores/{storeId}/routes
GET /api/stores/{storeId}/routes/{routeId}
DELETE /api/stores/{storeId}/routes/{routeId}

Controller delegates logic to RouteService.

Summary by CodeRabbit

  • New Features

    • Introduced route management API endpoints allowing you to create routes for stores, retrieve route details, and delete routes when no longer needed.
  • Chores

    • Updated Java toolchain compatibility and build configuration. Added new source directories to the project structure for improved organization.

@coderabbitai
Copy link

coderabbitai bot commented Mar 16, 2026

📝 Walkthrough

Walkthrough

A Java gradle build configuration was updated to use Java 21 toolchain, with additional source directories added. A new Spring REST controller for route management was introduced, exposing POST, GET, and DELETE endpoints that delegate to a RouteService.

Changes

Cohort / File(s) Summary
Build Configuration
build.gradle.kts
Updated Java toolchain language version from 25 to 21 and added new source directories for main Java source set: model and src/main/smithy.
Route Controller
src/main/java/com/shopping/inandout/routeservice/controller/RouteController.java
New Spring REST controller exposing three endpoints at /api/stores/{storeId}/routes for creating, retrieving, and deleting routes. Endpoints delegate to injected RouteService: POST (createRoute), GET (getRoute), DELETE (deleteRoute).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A controller hops in with routes so fine,
Spring beans dance in perfect line,
POST and GET and DELETE flow,
Through services where data goes,
In Java twenty-one we grow! 🌱

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a controller folder with a Route controller file, which aligns with the primary objective of implementing Route API endpoints.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can generate a title for your PR based on the changes with custom instructions.

Set the reviews.auto_title_instructions setting to generate a title for your PR based on the changes in the PR with custom instructions.

@sonarqubecloud
Copy link

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/main/java/com/shopping/inandout/routeservice/controller/RouteController.java (1)

16-19: Add @Valid to enforce request validation at the API boundary.

Bean Validation annotations on CreateRouteInput are not enforced unless the parameter is annotated with @Valid. Without it, invalid payloads bypass constraint checks.

Suggested fix
+import jakarta.validation.Valid;
 ...
     public RouteSummary createRoute(
             `@PathVariable` String storeId,
-            `@RequestBody` CreateRouteInput request) {
+            `@Valid` `@RequestBody` CreateRouteInput request) {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/main/java/com/shopping/inandout/routeservice/controller/RouteController.java`
around lines 16 - 19, The createRoute API method in RouteController currently
accepts CreateRouteInput without validation; annotate the request parameter with
`@Valid` (e.g., change the method signature in RouteController.createRoute to
accept `@Valid` `@RequestBody` CreateRouteInput request) and add the corresponding
javax.validation.Valid or jakarta.validation.Valid import so Bean Validation
constraints on CreateRouteInput are enforced at the API boundary.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@src/main/java/com/shopping/inandout/routeservice/controller/RouteController.java`:
- Around line 9-37: Add explicit import statements for the Smithy-generated
types used by RouteController: RouteService, CreateRouteInput, and RouteSummary
— import them from the package declared in your Smithy-generated outputs (the
generated model/service package) at the top of RouteController.java so the
controller can compile; ensure the imported package matches the Smithy output
package and resolve any naming collisions by using fully qualified imports if
needed.

---

Nitpick comments:
In
`@src/main/java/com/shopping/inandout/routeservice/controller/RouteController.java`:
- Around line 16-19: The createRoute API method in RouteController currently
accepts CreateRouteInput without validation; annotate the request parameter with
`@Valid` (e.g., change the method signature in RouteController.createRoute to
accept `@Valid` `@RequestBody` CreateRouteInput request) and add the corresponding
javax.validation.Valid or jakarta.validation.Valid import so Bean Validation
constraints on CreateRouteInput are enforced at the API boundary.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 23bc9f48-4ac1-4433-b76a-f8bf14ccdf3d

📥 Commits

Reviewing files that changed from the base of the PR and between df345a1 and 3c666d5.

📒 Files selected for processing (2)
  • build.gradle.kts
  • src/main/java/com/shopping/inandout/routeservice/controller/RouteController.java

Comment on lines +9 to +37
private final RouteService routeService;

public RouteController(RouteService routeService) {
this.routeService = routeService;
}

@PostMapping
public RouteSummary createRoute(
@PathVariable String storeId,
@RequestBody CreateRouteInput request) {

return routeService.createRoute(storeId, request);
}

@GetMapping("/{routeId}")
public RouteSummary getRoute(
@PathVariable String storeId,
@PathVariable String routeId) {

return routeService.getRoute(storeId, routeId);
}

@DeleteMapping("/{routeId}")
public RouteSummary deleteRoute(
@PathVariable String storeId,
@PathVariable String routeId) {

return routeService.deleteRoute(storeId, routeId);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "RouteController imports and referenced symbols:"
sed -n '1,80p' src/main/java/com/shopping/inandout/routeservice/controller/RouteController.java

echo
echo "Locate declarations for RouteService, CreateRouteInput, RouteSummary:"
rg -n --type=java -C2 '^\s*(public\s+)?(class|interface|record)\s+(RouteService|CreateRouteInput|RouteSummary)\b|^\s*package\s+'

Repository: InAndOut-Stack/InAndOut-Route-Service

Length of output: 2238


🏁 Script executed:

# Search for RouteService definition
echo "=== Searching for RouteService ===" 
rg -n "class\s+RouteService|interface\s+RouteService" --type=java

echo
echo "=== Searching for CreateRouteInput definition ===" 
rg -n "class\s+CreateRouteInput|record\s+CreateRouteInput" --type=java

echo
echo "=== Searching for RouteSummary definition ===" 
rg -n "class\s+RouteSummary|record\s+RouteSummary|interface\s+RouteSummary" --type=java

echo
echo "=== All Java files in src/main ===" 
find src/main -name "*.java" -type f

Repository: InAndOut-Stack/InAndOut-Route-Service

Length of output: 649


🏁 Script executed:

# Check for build files
echo "=== Build files ==="
ls -la | grep -E "pom.xml|build.gradle|build.gradle.kts"

# Check pom.xml for dependencies if it exists
if [ -f pom.xml ]; then
  echo
  echo "=== pom.xml dependencies ==="
  head -50 pom.xml
fi

# Check if RouteController file is complete
echo
echo "=== Full RouteController.java ==="
cat src/main/java/com/shopping/inandout/routeservice/controller/RouteController.java

Repository: InAndOut-Stack/InAndOut-Route-Service

Length of output: 1210


🏁 Script executed:

cat build.gradle.kts

Repository: InAndOut-Stack/InAndOut-Route-Service

Length of output: 3815


Add missing imports for Smithy-generated types.

RouteService, CreateRouteInput, and RouteSummary are generated by Smithy and are not in the controller package. This file requires explicit imports for these types to compile.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/main/java/com/shopping/inandout/routeservice/controller/RouteController.java`
around lines 9 - 37, Add explicit import statements for the Smithy-generated
types used by RouteController: RouteService, CreateRouteInput, and RouteSummary
— import them from the package declared in your Smithy-generated outputs (the
generated model/service package) at the top of RouteController.java so the
controller can compile; ensure the imported package matches the Smithy output
package and resolve any naming collisions by using fully qualified imports if
needed.

@narenkarthik370h
Copy link
Author

@petrubraha can you check and give review over this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant